<template>
  <el-date-picker
    @change="change"
    v-model="currentDate"
    :type="type"
    :size="size"
    :placeholder="placeholder">
  </el-date-picker>
</template>
<script>
import {dateFormat} from '@/utils'
export default {
  data () {
    return {
      currentDate: `${new Date()}`,
      currentDate1: new Date()
    }
  },
  mounted () {
    this.currentDate = this.value
  },
  props: {
    placeholder: {
      type: String,
      default: () => {
        return '请选择时间'
      }
    },
    format: {
      type: String,
      default: () => {
        return 'yyyy-MM-dd'
      }
    },
    value: { // 选中的配置
      type: String,
      default: () => {
        return ''
      }
    },
    type: {
      type: String,
      default: () => {
        return 'datetime'
      }
    },
    size: {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  methods: {
    change () {
      this.$emit('input', dateFormat(this.currentDate, this.format))
    }
  },
  watch: {
    value (nv) {
      this.currentDate = nv
    }
  }
}
</script>
